home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / CIncludes / MachineExceptions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-17  |  3.7 KB  |  171 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        MachineExceptions.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __MACHINEEXCEPTIONS__
  18. #define __MACHINEEXCEPTIONS__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29.  
  30. #if GENERATINGPOWERPC
  31. #pragma options align=mac68k
  32. #endif
  33.  
  34. #ifdef __CFM68K__
  35. #pragma lib_export on
  36. #endif
  37.  
  38. typedef void *Ref;
  39.  
  40. typedef long OSStatus;
  41.  
  42. typedef Ref AreaID;
  43.  
  44. typedef Ref LogicalAddress;
  45.  
  46. /* Machine Dependent types for PowerPC */
  47. struct MachineInformation {
  48.     UnsignedWide                    CTR;
  49.     UnsignedWide                    LR;
  50.     UnsignedWide                    PC;
  51.     unsigned long                    CR;
  52.     unsigned long                    XER;
  53.     unsigned long                    MSR;
  54. };
  55. typedef struct MachineInformation MachineInformation;
  56.  
  57. struct RegisterInformation {
  58.     UnsignedWide                    R0;
  59.     UnsignedWide                    R1;
  60.     UnsignedWide                    R2;
  61.     UnsignedWide                    R3;
  62.     UnsignedWide                    R4;
  63.     UnsignedWide                    R5;
  64.     UnsignedWide                    R6;
  65.     UnsignedWide                    R7;
  66.     UnsignedWide                    R8;
  67.     UnsignedWide                    R9;
  68.     UnsignedWide                    R10;
  69.     UnsignedWide                    R11;
  70.     UnsignedWide                    R12;
  71.     UnsignedWide                    R13;
  72.     UnsignedWide                    R14;
  73.     UnsignedWide                    R15;
  74.     UnsignedWide                    R16;
  75.     UnsignedWide                    R17;
  76.     UnsignedWide                    R18;
  77.     UnsignedWide                    R19;
  78.     UnsignedWide                    R20;
  79.     UnsignedWide                    R21;
  80.     UnsignedWide                    R22;
  81.     UnsignedWide                    R23;
  82.     UnsignedWide                    R24;
  83.     UnsignedWide                    R25;
  84.     UnsignedWide                    R26;
  85.     UnsignedWide                    R27;
  86.     UnsignedWide                    R28;
  87.     UnsignedWide                    R29;
  88.     UnsignedWide                    R30;
  89.     UnsignedWide                    R31;
  90. };
  91. typedef struct RegisterInformation RegisterInformation;
  92.  
  93. struct FPUInformation {
  94.     UnsignedWide                    Registers[32];
  95.     unsigned long                    FPSCR;
  96. };
  97. typedef struct FPUInformation FPUInformation;
  98.  
  99. /* Exception related declarations */
  100.  
  101. enum {
  102.     writeReference                = 0,
  103.     readReference                = 1,
  104.     fetchReference                = 2
  105. };
  106.  
  107. typedef unsigned long MemoryReferenceKind;
  108.  
  109. struct MemoryExceptionInformation {
  110.     AreaID                            theArea;
  111.     LogicalAddress                    theAddress;
  112.     OSStatus                        theError;
  113.     MemoryReferenceKind                theReference;
  114. };
  115. typedef struct MemoryExceptionInformation MemoryExceptionInformation;
  116.  
  117.  
  118. enum {
  119.     unknownException            = 0,
  120.     illegalInstructionException    = 1,
  121.     trapException                = 2,
  122.     accessException                = 3,
  123.     unmappedMemoryException        = 4,
  124.     excludedMemoryException        = 5,
  125.     readOnlyMemoryException        = 6,
  126.     unresolvablePageFaultException = 7,
  127.     privilegeViolationException    = 8,
  128.     traceException                = 9,
  129.     instructionBreakpointException = 10,
  130.     dataBreakpointException        = 11,
  131.     integerException            = 12,
  132.     floatingPointException        = 13,
  133.     stackOverflowException        = 14,
  134.     terminationException        = 15
  135. };
  136.  
  137. typedef unsigned long ExceptionKind;
  138.  
  139. union ExceptionInfo {
  140.     MemoryExceptionInformation        *memoryInfo;
  141. };
  142. typedef union ExceptionInfo ExceptionInfo;
  143.  
  144. struct ExceptionInformation {
  145.     ExceptionKind                    theKind;
  146.     MachineInformation                *machineState;
  147.     RegisterInformation                *registerImage;
  148.     FPUInformation                    *FPUImage;
  149.     ExceptionInfo                    info;
  150. };
  151. typedef struct ExceptionInformation ExceptionInformation;
  152.  
  153. /* Note: An ExceptionHandler is NOT a UniversalProcPtr. It must be
  154.    a native PowerPC transition vector with NO routine descriptor. */
  155. typedef    OSStatus (*ExceptionHandler) (ExceptionInformation *theException);
  156. ExceptionHandler InstallExceptionHandler (ExceptionHandler theHandler);
  157.  
  158. #ifdef __CFM68K__
  159. #pragma lib_export off
  160. #endif
  161.  
  162. #if GENERATINGPOWERPC
  163. #pragma options align=reset
  164. #endif
  165.  
  166. #ifdef __cplusplus
  167. }
  168. #endif
  169.  
  170. #endif /* __MACHINEEXCEPTIONS__ */
  171.